package sprintServer.start;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import sprintServer.dbconnect.Conn;
public class ServerLogin {

	StringBuffer sql = new StringBuffer();
	Connection con ;
	PreparedStatement pstmt;
	ResultSet rs;
	
	public String login(String id, String pw){
		String result="";
		String pass;
		sql.append("select pass from member ");
		sql.append("where id = ?");
		try{
			con = Conn.getConnection();
			pstmt = con.prepareStatement(sql.toString());
			pstmt.setString(1, id);
			rs = pstmt.executeQuery();
			while(rs.next()){
				pass = rs.getString("pass");
				System.out.println("서버 패스워크 : "+pass);
				if(pw.trim().equals(pass.trim())){
					result = "success";

				}else{
					result = "false";
				}
			}
			
		}catch(SQLException se){
			System.out.println("에러 :"+se.toString());
		}
		finally{
			try{if(rs != null)rs.close();}catch	(SQLException se1){}
			try{if(pstmt != null)pstmt.close();}catch	(SQLException se1){}
			try{if(con != null)con.close();}catch	(SQLException se1){}			
		}
		return result;
	}
}
